package cn.alm.allinoneboot.interceptor;

import cn.alm.allinoneboot.common.CommonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ControllerAdvicer {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public CommonResult handlerException(Exception e) {
        String message = e.getMessage();
//        System.out.println("message = " + message);
        CommonResult cr = new CommonResult();
        cr.setSuccess(false);
        cr.setCode(500);
        cr.setMessage(message);
        return cr;
    }

}
